<template xmlns="http://www.w3.org/1999/html">
  <a-card :bordered="false">

    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="12">
          <a-col :md="7" :sm="8">
            <a-form-item label="字典名称" :label-col="{span: 6}" :wrapper-col="{span: 14, offset: 1}">
              <a-input v-model="queryParam.dictName" placeholder="请输入字典名称"/>
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <a-form-item label="字典编号" :label-col="{span: 6}" :wrapper-col="{span: 14, offset: 1}">
              <a-input v-model="queryParam.dictCode" placeholder="请输入字典编号"/>
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <div v-if="selectedRowKeys.length > 0" class="table-operator" style="border-top: 5px">
      <a-dropdown>
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"/> 已选择 <a
        style="font-weight: 600"
      >{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        size="middle"
        bordered
        row-key="id"
        :columns="columns"
        :data-source="dataSource"
        :pagination="pagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"/>
        </template>
        <!-- 字符串超长截取省略号显示-->
        <span slot="logContent" slot-scope="text">
          <ants-ellipsis :value="text" :length="40"/>
        </span>
        <span slot="files" slot-scope="text">
          <ants-ellipsis :value="text" :length="40"/>
        </span>

        <span slot="action" slot-scope="text, record">
        <a-popconfirm title="确定删除吗?" @confirm="() =>handleDelete(record.id)">
          <a>删除</a>
        </a-popconfirm>
      </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import {TableListMixin} from '@/mixins/TableListMixin'
import AntsEllipsis from '@/components/ants/AntsEllipsis'

export default {
  name: 'sendMailHistory',
  mixins: [TableListMixin],
  components: {
    AntsEllipsis
  },
  data() {
    return {
      description: '文章管理',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '发件人',
          align: 'center',
          dataIndex: 'sender'
        },
        {
          title: '收件人',
          align: 'center',
          dataIndex: 'addressee'
        },
        {
          title: '标题',
          align: 'center',
          dataIndex: 'title'
        },
        {
          title: '内容',
          align: 'center',
          dataIndex: 'content',
          scopedSlots: {customRender: 'logContent'}
        },
        {
          title: '附件',
          align: 'center',
          dataIndex: 'files',
          scopedSlots: {customRender: 'files'}
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'state',
          width: 75,
        },
        {
          title: '操作',
          align: 'center',
          dataIndex: 'action',
          width: 75,
          scopedSlots: {customRender: 'action'}
        }
      ],
      url: {
        list: '/mail/tool/',
        delete: '/mail/tool/delete',
        deleteBatch: '/article/deleteBatch'
      }
    }
  },
  methods: {}
}
</script>
